package outoforder.leetcode;


import org.junit.Test;

/**
 * @author shhjiang_001
 * @create 2020-07-04 17:52
 */
public class SolutionPacker {
    public int mostValue(int[] wt,int[] val, int W,int N){
        int[][] dp = new int[N+1][W+1];
        for (int n = 1; n <= N ; n++) {
            for (int w = 1; w <= W ; w++) {
                if (w-wt[n-1] < 0){
                    dp[n][w] = dp[n-1][w];
                }else {
                    dp[n][w] = Math.max(dp[n-1][w-wt[n-1]]+val[n-1],dp[n-1][w]);
                }
            }
        }
        return dp[N][W];
    }
    @Test
    public void test(){
        mostValue(new int[]{2,1,3},new int[]{4,2,3},4,3);
    }
}
